using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace Coding4Fun.Phone.Controls.Toolkit.Primitives
{
	[TemplatePart(Name = "Transform", Type = typeof(TranslateTransform)), TemplateVisualState(GroupName = "Common", Name = "Normal"), TemplateVisualState(GroupName = "Common", Name = "Selected"), TemplateVisualState(GroupName = "Common", Name = "Expanded")]
	public class LoopingSelectorItem : ContentControl
	{
		internal enum Enum1
		{
			const_0,
			const_1,
			const_2
		}
		private const string string_0 = "Transform";
		private const string string_1 = "Common";
		private const string string_2 = "Normal";
		private const string string_3 = "Expanded";
		private const string string_4 = "Selected";
		private bool bool_0;
		private LoopingSelectorItem.Enum1 enum1_0;
		private EventHandler<EventArgs> eventHandler_0;
		[CompilerGenerated]
		private LoopingSelectorItem loopingSelectorItem_0;
		[CompilerGenerated]
		private LoopingSelectorItem loopingSelectorItem_1;
		[CompilerGenerated]
		private TranslateTransform translateTransform_0;
		public event EventHandler<EventArgs> Click
		{
			add
			{
				EventHandler<EventArgs> eventHandler = this.eventHandler_0;
				EventHandler<EventArgs> eventHandler2;
				do
				{
					eventHandler2 = eventHandler;
					EventHandler<EventArgs> eventHandler3 = (EventHandler<EventArgs>)Delegate.Combine(eventHandler2, value);
					eventHandler = Interlocked.CompareExchange<EventHandler<EventArgs>>(ref this.eventHandler_0, eventHandler3, eventHandler2);
				}
				while (eventHandler != eventHandler2);
			}
			remove
			{
				EventHandler<EventArgs> eventHandler = this.eventHandler_0;
				EventHandler<EventArgs> eventHandler2;
				do
				{
					eventHandler2 = eventHandler;
					EventHandler<EventArgs> eventHandler3 = (EventHandler<EventArgs>)Delegate.Remove(eventHandler2, value);
					eventHandler = Interlocked.CompareExchange<EventHandler<EventArgs>>(ref this.eventHandler_0, eventHandler3, eventHandler2);
				}
				while (eventHandler != eventHandler2);
			}
		}
		internal LoopingSelectorItem Previous
		{
			get;
			private set;
		}
		internal LoopingSelectorItem Next
		{
			get;
			private set;
		}
		internal TranslateTransform Transform
		{
			get;
			private set;
		}
		public LoopingSelectorItem()
		{
			base.set_DefaultStyleKey(typeof(LoopingSelectorItem));
			base.add_MouseLeftButtonDown(new MouseButtonEventHandler(this.LoopingSelectorItem_MouseLeftButtonDown));
			base.add_MouseLeftButtonUp(new MouseButtonEventHandler(this.LoopingSelectorItem_MouseLeftButtonUp));
			base.add_LostMouseCapture(new MouseEventHandler(this.LoopingSelectorItem_LostMouseCapture));
			base.add_Tap(new EventHandler<GestureEventArgs>(this.method_2));
		}
		internal void method_0(LoopingSelectorItem.Enum1 enum1_1, bool bool_1)
		{
			if (this.enum1_0 != enum1_1)
			{
				this.enum1_0 = enum1_1;
				switch (this.enum1_0)
				{
				case LoopingSelectorItem.Enum1.const_0:
					VisualStateManager.GoToState(this, "Normal", bool_1);
					return;
				case LoopingSelectorItem.Enum1.const_1:
					VisualStateManager.GoToState(this, "Expanded", bool_1);
					return;
				case LoopingSelectorItem.Enum1.const_2:
					VisualStateManager.GoToState(this, "Selected", bool_1);
					break;
				default:
					return;
				}
			}
		}
		internal LoopingSelectorItem.Enum1 method_1()
		{
			return this.enum1_0;
		}
		private void method_2(object sender, GestureEventArgs e)
		{
			e.set_Handled(true);
		}
		private void LoopingSelectorItem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
			base.CaptureMouse();
			this.bool_0 = true;
		}
		private void LoopingSelectorItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
		{
			base.ReleaseMouseCapture();
			if (this.bool_0)
			{
				this.bool_0 = false;
				Class33.smethod_1(this.eventHandler_0, this);
			}
		}
		private void LoopingSelectorItem_LostMouseCapture(object sender, MouseEventArgs e)
		{
			this.bool_0 = false;
		}
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			this.Transform = ((base.GetTemplateChild("Transform") as TranslateTransform) ?? new TranslateTransform());
		}
		internal void method_3()
		{
			if (this.Previous != null)
			{
				this.Previous.Next = this.Next;
			}
			if (this.Next != null)
			{
				this.Next.Previous = this.Previous;
			}
			this.Next = (this.Previous = null);
		}
		internal void method_4(LoopingSelectorItem loopingSelectorItem_2)
		{
			this.Next = loopingSelectorItem_2.Next;
			this.Previous = loopingSelectorItem_2;
			if (loopingSelectorItem_2.Next != null)
			{
				loopingSelectorItem_2.Next.Previous = this;
			}
			loopingSelectorItem_2.Next = this;
		}
		internal void method_5(LoopingSelectorItem loopingSelectorItem_2)
		{
			this.Next = loopingSelectorItem_2;
			this.Previous = loopingSelectorItem_2.Previous;
			if (loopingSelectorItem_2.Previous != null)
			{
				loopingSelectorItem_2.Previous.Next = this;
			}
			loopingSelectorItem_2.Previous = this;
		}
	}
}
